package com.qfedu.service.impl;

import com.qfedu.dao.CategoryDao;
import com.qfedu.dao.impl.CategoryDaoImpl;
import com.qfedu.pojo.Category;
import com.qfedu.service.CategoryService;

import java.util.List;

public class CategoryServiceImpl implements CategoryService {
    CategoryDao categoryDao=new CategoryDaoImpl();

    @Override
    public void deleteManyCateById(List<String> list) {

        list.stream().forEach(cid->{
            Category category = categoryDao.fidCateById(cid);
            if (category!=null)  {
                int i = categoryDao.deleteCateById(category.getCid());
            }
        });

    }

    @Override
    public int deleteCateById(String cid) {
        int rows = categoryDao.deleteCateById(cid);

        return rows;
    }

    @Override
    public int updateCategory(Category category,String cid) {
        int rows = categoryDao.updateCategory(category,cid);
        return rows;
    }

    @Override
    public int createCategory(Category category) {
        int rows = categoryDao.createCategory(category);
        return rows;
    }

    @Override
    public List findAllCategory() {
        List<Category> list = categoryDao.findAllCategory();
        return list;
    }

    @Override
    public Category fidCateById(String id) {
        Category category = categoryDao.fidCateById(id);
        return category;
    }
}
